#ifndef PATHDELETE_H
#define PATHDELETE_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>

#include "filedata_t.h"
#include "configfile.h"

class PathDelete : public QObject
{
    Q_OBJECT
public:
    enum Status {
        NO_ERROR,
        /* customer error */
        INVALID_NAME,
        INVALID_PHPSESSID,
        INVALID_FILE_DATA_LIST,
        JSON_ERROR,

        /* network error */
        RESPONSE_ERROR,

        UNDEFINED_ERROR = -1,
    };
    static inline QString errorString(Status code) {
        switch (code) {
        case NO_ERROR               : return "Succeed";
        case INVALID_NAME           : return "Invalid user name";
        case INVALID_PHPSESSID      : return "Invalid PHPSESSID";
        case INVALID_FILE_DATA_LIST : return "Invalid file data list";
        case UNDEFINED_ERROR        : return "Undefined error";
        default                     : return "The mistake of the mistake";
        }
    }
    explicit PathDelete(QObject *parent = nullptr);
    ~PathDelete();
    Status startPathDelete(QList<file_t> fileDataList, QString currentNetPath = "");
    bool isDeleting();
    Status stopPathDelete();

signals:
    void finished(int code, QString errorString);
private slots:
    void deleteResponse(QNetworkReply *reply);

private: /* var */
    ConfigFile *            settings;
    bool                    deleting;
    QNetworkAccessManager   *netManager;
    QNetworkRequest         *baseRequest;


private: /* func */
    Status init();

};

#endif // PATHDELETE_H
